<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>修改页面</title>
    <link rel="shortcut icon" href="/assets/images/favicon.ico" type="image/x-icon"/>
    <link rel="stylesheet" href="/assets/pear/css/pear.css"/>
</head>
<body>
<form class="layui-form" action="" lay-filter="lay-edit">
    <div class="mainBox">
        <div class="main-container">
            <div class="layui-col-md6">
                <div class="layui-form-item">
                    <label class="layui-form-label">账号</label>
                    <div class="layui-input-block">
                        <input type="text" name="userName" value="" disabled class="layui-input">
                        <input type="hidden" name="userId" value="" disabled class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-col-md6">
                <div class="layui-form-item">
                    <label class="layui-form-label">姓名</label>
                    <div class="layui-input-block">
                        <input type="text" name="nickName" lay-verify="required" autocomplete="off"
                               placeholder="请输入姓名"
                               class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-col-md6">
                <div class="layui-form-item">
                    <label class="layui-form-label">密码</label>
                    <div class="layui-input-block">
                        <input type="text" name="password" value="******" lay-verify="required" autocomplete="off"
                               lay-affix="eye" placeholder="请输入密码" class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-col-md6">
                <div class="layui-form-item">
                    <label class="layui-form-label">电话</label>
                    <div class="layui-input-block">
                        <input type="text" name="phoneNumber" value="" lay-verify="required" autocomplete="off"
                               placeholder="请输入电话" class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-col-md6">
                <div class="layui-form-item">
                    <label class="layui-form-label">性别</label>
                    <div class="layui-input-block">
                        <input type="radio" name="sex" value="1" title="男">
                        <input type="radio" name="sex" value="2" title="女" checked>
                    </div>
                </div>
            </div>
            <div class="layui-row">
                <div class="layui-form-item">
                    <label class="layui-form-label">用户类型</label>
                    <div class="layui-input-block">
                        <input type="radio" name="userType" value="00" title="系统用户">
                        <input type="radio" name="userType" value="1" title="普通用户" checked>
                    </div>
                </div>
            </div>
            <div class="layui-row">
                <div class="layui-form-item">
                    <label class="layui-form-label">备注</label>
                    <div class="layui-input-block">
                        <textarea name="remark" placeholder="请输入备注" class="layui-textarea"></textarea>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit=""
                    lay-filter="user-save">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button id="close" class="pear-btn pear-btn-sm">
                <i class="layui-icon layui-icon-close"></i>
                关闭
            </button>
        </div>
    </div>
</form>
<script src="/assets/layui/layui.js"></script>
<script src="/assets/pear/pear.js"></script>
<script>
    layui.use(['form', 'jquery', 'userApi'], function () {
        let form = layui.form;
        let $ = layui.jquery;
        var userApi = layui.userApi;
        var loadIndex = layer.load(0);
        var url = layui.url()
        userApi.get(url.search.id).then(res => {
            form.val('lay-edit', res.data);
        }).finally(() => {
            layer.close(loadIndex)
        })

        form.on('submit(user-save)', function (data) {
            userApi.edit(data.field).then(res => {
                closeWindowToMain()
                searchIframeBySrc('user.html').layui.table.reload("user-table");
                parent.layer.msg('更新成功')
            })
            return false;
        });
        $('#close').click(() => {
            closeWindowToMain()
        })
    })
</script>
<script>
</script>
</body>
</html>
